﻿using UnityEngine;
using System.Collections;
using UnityEditor;

namespace Hont.HyperWigglePackage.Editor
{
    public class EditorAssetsCache
    {
        public static Texture InvalidWiggleTex;
        public static Mesh CubemapMesh;
        public static Mesh PreviewCube;
        public static Mesh PreviewCapsule;
        public static Material PreviewMaterial;

        public static Material cubemap01Material;
        public static Material cubemap02Material;
        public static Material cubemap03Material;


        static EditorAssetsCache()
        {
            var path = _HyperWiggleLocation.GetAssetsPath();

            InvalidWiggleTex = AssetDatabase.LoadAssetAtPath<Texture>(path + "/InvalidWiggle.png");

            var previewGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(path + "/PreviewCube.prefab");
            PreviewCube = previewGameObject.GetComponent<MeshFilter>().sharedMesh;

            previewGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(path + "/PreviewCapsule.prefab");
            PreviewCapsule = previewGameObject.GetComponent<MeshFilter>().sharedMesh;

            PreviewMaterial = AssetDatabase.LoadAssetAtPath<Material>(path + "/DefaultMat.mat");

            var cubemapGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(path + "/CubemapMesh.prefab");
            CubemapMesh = cubemapGameObject.GetComponent<MeshFilter>().sharedMesh;

            cubemap01Material = AssetDatabase.LoadAssetAtPath<Material>(path + "/Cubemaps/CubemapMat01.mat");
            cubemap02Material = AssetDatabase.LoadAssetAtPath<Material>(path + "/Cubemaps/CubemapMat02.mat");
            cubemap03Material = AssetDatabase.LoadAssetAtPath<Material>(path + "/Cubemaps/CubemapMat03.mat");
        }
    }
}
